﻿//-----------------------------------------------------------------------------------------
// <copyright file="Common.cs" company="Jakub Florczyk (www.jakubflorczyk.pl)">
//      Copyright © 2009 Jakub Florczyk (www.jakubflorczyk.pl)
//      http://samsungmobilesdknet.codeplex.com
// </copyright>
//-----------------------------------------------------------------------------------------

namespace SamsungMobileSDKNET
{
    using System;
    using System.Runtime.InteropServices;

    /// <summary>
    /// Common result codes.
    /// </summary>
    public enum ResultCode
    {
        /// <summary>
        /// Success result.
        /// </summary>
        Success = 0x00000000,

        /// <summary>
        /// Unknown error.
        /// </summary>
        ErrorUnknown = 0x00000001,

        /// <summary>
        /// Device not found error.
        /// </summary>
        ErrorDeviceNotFound = 0x00000002,

        /// <summary>
        /// Device disable error.
        /// </summary>
        ErrorDevideDisabled = 0x00000003,

        /// <summary>
        /// Permission denied error.
        /// </summary>
        ErrorPermissionDenied = 0x00000004,

        /// <summary>
        /// Invalid parameter error.
        /// </summary>
        ErrorInvalidParameter = 0x00000005,

        /// <summary>
        /// Cannot activate server error.
        /// </summary>
        ErrorCannonActivateServer = 0x00000006,

        /// <summary>
        /// Feature not supported error.
        /// </summary>
        ErrorFeatureNotSupported = 0x00000007,

        /// <summary>
        /// Accelerometer result base.
        /// </summary>
        AccelerometerResultBase = 0x10010000,

        /// <summary>
        /// Haptics result base.
        /// </summary>
        HapticsResultBase = 0x10020000,

        /// <summary>
        /// Led result base.
        /// </summary>
        LedResultBase = 0x10030000,

        /// <summary>
        /// Camera result base.
        /// </summary>
        CameraResultBase = 0x10040000,

        /// <summary>
        /// R2VS result base.
        /// </summary>
        R2VSResultBase = 0x10050000,

        /// <summary>
        /// Reserved for future use.
        /// </summary>
        Reserved = 0x1F000000
    }

    /// <summary>
    /// The version of the API.
    /// </summary>
    [StructLayout(LayoutKind.Sequential)]
    public struct Version
    {
        /// <summary>
        /// The API’s major version.
        /// </summary>
        public uint Major;

        /// <summary>
        /// The API’s minor version.
        /// </summary>
        public uint Minor;

        /// <summary>
        /// The API’s patch version.
        /// </summary>
        public uint Patch;
    }

    /// <summary>
    /// Common items used by all APIs.
    /// </summary>
    public class Common
    {
        /// <summary>
        /// Library name.
        /// </summary>
        internal const string DllName = "SamsungMobileSDK_2.dll";

        /// <summary>
        /// Gets the current SDK version installed on the device.
        /// </summary>
        /// <param name="version">The SDK version number, unless NULL is passed in for version.</param>
        /// <returns>The SDK version description, in null-terminated wide character string format (even if NULL is passed in for version).</returns>
        [DllImport(DllName, EntryPoint = "SmiGetSdkVersion")]
        public static extern IntPtr GetSdkVersion(
            [Out] out Version version);

        /// <summary>
        /// Returns whether the SDK supports the current phone model.
        /// </summary>
        /// <returns>TRUE if supported, FALSE otherwise.</returns>
        [DllImport(DllName, EntryPoint = "SmiIsPhoneSupported")]
        public static extern bool IsPhoneSupported();
    }    
}
